# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        潘炎珍  
# Name:         demo02
# Description:
# Author:       98745
# Date:         2019/3/10
#-------------------------------------------------------------------------------

import dicttoxml
from xml.dom.minidom import parseString
import os
d=[20,'names',{'name':'bill','age':30,'salarly':2000},{'name':'王军','age':34,'salary':3000},{'name':'john','age':25,'salary':2500}]
b=dicttoxml.dicttoxml(d,custom_root='persons')
xml=b.decode('utf-8')
print(xml)
dom=parseString(xml)
p=dom.toprettyxml(indent='')
f=open('files/persons.xml','w',encoding='utf-8')
f.write(p)
f.close()